package com.simen.hellobytes.rpc.rmi;

import javax.naming.NamingException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * author: SimenHi
 * create time: 2020-12-14 10:06
 * description:
 */
public class RMIClientTest {
    public static void main(String[] args) throws NamingException, RemoteException, MalformedURLException, NotBoundException {
        System.out.println("RMI registry binding:");
        String url = (args==null || args.length==0)?"rmi://localhost:1099/central_warehoues":args[0];
        Warehouse centralWarehouse = (Warehouse) Naming.lookup(url);
        String descr = "mate7";
        double price = centralWarehouse.getPrice(descr);
        System.out.println(descr + ":" + price);
    }
}
